

/**
 * $RCSfile: ConnectionPoolManager.java,v $
 * $Revision: 1.2 $
 * $Date: 2000/12/21 17:47:20 $
 *
 */

package com.ec.core.db;

import java.sql.*;
import java.util.Calendar;
import java.math.BigDecimal;
import java.net.URL;
import java.io.InputStream;
import java.util.Map;
import java.io.Reader;

public class PooledCallableStatement extends PooledPreparedStatement implements CallableStatement {

	private static int pcscount=0;
	protected CallableStatement cstmt;
	private static com.ec.core.util.Logging  cat = com.ec.core.util.Logging.getLog("dbpool");

	public PooledCallableStatement(CallableStatement stmt) {
		PooledCallableStatement.pcscount++;
		this.stmt = stmt;
		this.cstmt = (CallableStatement)cstmt;
                cat.debug("PooledCallableStatement created!!["+PooledCallableStatement.pcscount+"]");
	}

	public void close() throws SQLException
	{
		//changed by stephen
		try
		{
			if(cstmt!=null)
			{
				cstmt.close();
				PooledCallableStatement.pcscount--;
			}
                        cat.debug("PooledCallableStatement closed!!["+PooledCallableStatement.pcscount+"]");
		}
		catch(SQLException e)
		{
			throw e;
		}
	}



	/**************************************************************************
	 *
	 * CallableStatment methods
	 *
	 **************************************************************************/

	public void registerOutParameter(int index, int type) throws SQLException {
		cstmt.registerOutParameter(index, type);
	}

	public void registerOutParameter(int index, int type, int scale) throws SQLException {
		cstmt.registerOutParameter(index, type, scale);
	}

	public boolean wasNull() throws SQLException {
		return cstmt.wasNull();
	}

	/**
	 *@deprecated
	 */
	public BigDecimal getBigDecimal(int index, int scale) throws SQLException {
		return cstmt.getBigDecimal(index, scale);
	}

	public boolean getBoolean(int index) throws SQLException {
		return cstmt.getBoolean(index);
	}

	public byte getByte(int index) throws SQLException {
		return cstmt.getByte(index);
	}

	public byte[] getBytes(int index) throws SQLException {
		return cstmt.getBytes(index);
	}

	public Date getDate(int index) throws SQLException {
		return cstmt.getDate(index);
	}

	public double getDouble(int index) throws SQLException {
		return cstmt.getDouble(index);
	}

	public float getFloat(int index) throws SQLException {
		return cstmt.getFloat(index);
	}

	public int getInt(int index) throws SQLException {
		return cstmt.getInt(index);
	}

	public long getLong(int index) throws SQLException {
		return cstmt.getLong(index);
	}

	public Object getObject(int index) throws SQLException {
		return cstmt.getObject(index);
	}

	public short getShort(int index) throws SQLException {
		return cstmt.getShort(index);
	}

	public String getString(int index) throws SQLException {
		return cstmt.getString(index);
	}

	public Time getTime(int index) throws SQLException {
		return cstmt.getTime(index);
	}

	public Timestamp getTimestamp(int index) throws SQLException {
		return cstmt.getTimestamp(index);
	}


	public java.sql.Time getTime(int i , java.util.Calendar c)  throws SQLException {
		return cstmt.getTime(i,c);
	}
	public java.sql.Clob getClob(int i) throws SQLException  {
		return cstmt.getClob(i);
	}
	public java.math.BigDecimal getBigDecimal(int i)  throws SQLException {
		return cstmt.getBigDecimal(i);
	}
	public void registerOutParameter(int i, int j, java.lang.String s)  throws SQLException {
		cstmt.registerOutParameter(i,j,s);
	}
	public java.sql.Timestamp getTimestamp(int i, java.util.Calendar c)  throws SQLException {
		return cstmt.getTimestamp(i,c);
	}
	public java.sql.Blob getBlob(int i)  throws SQLException {
		return cstmt.getBlob(i);
	}
	public java.sql.Array getArray(int i)  throws SQLException {
		return cstmt.getArray(i);
	}
	public java.sql.Ref getRef(int i)  throws SQLException {
		return cstmt.getRef(i);
	}
	public java.sql.Date getDate(int i, java.util.Calendar c)  throws SQLException {
		return cstmt.getDate(i,c);
	}
	public java.lang.Object getObject(int i, java.util.Map m)  throws SQLException {
		return cstmt.getObject(i,m);
	}

	///////////////////////////1.4
	public void setNull(String parameterName,
			int sqlType)
	throws SQLException
	{
		cstmt.setNull(parameterName, sqlType);
	}
	public void registerOutParameter(String parameterName,
			int sqlType)
	throws SQLException
	{
		cstmt.registerOutParameter(parameterName, sqlType);
	}
	public void registerOutParameter(String parameterName,
			int sqlType,
			int scale)
	throws SQLException
	{
		cstmt.registerOutParameter(parameterName, sqlType, scale);
	}
	public void registerOutParameter(String parameterName,
			int sqlType,
			String typeName)
	throws SQLException
	{
		cstmt.registerOutParameter(parameterName, sqlType, typeName);
	}
	public URL getURL(int parameterIndex)
	throws SQLException
	{
		return cstmt.getURL(parameterIndex);
	}
	public void setURL(String parameterName,
			URL val)
	throws SQLException
	{
		cstmt.setURL(parameterName, val);
	}
	public void setBoolean(String parameterName,
			boolean x)
	throws SQLException
	{
		cstmt.setBoolean(parameterName, x);
	}
	public void setByte(String parameterName,
			byte x)
	throws SQLException
	{
		cstmt.setByte(parameterName, x);
	}
	public void setShort(String parameterName,
			short x)
	throws SQLException
	{
		cstmt.setShort(parameterName, x);
	}

	public void setInt(String parameterName,
			int x)
	throws SQLException
	{
		cstmt.setInt(parameterName, x);
	}
	public void setLong(String parameterName,
			long x)
	throws SQLException
	{
		cstmt.setLong(parameterName, x);
	}
	public void setFloat(String parameterName,
			float x)
	throws SQLException
	{
		cstmt.setFloat(parameterName, x);
	}
	public void setDouble(String parameterName,
			double x)
	throws SQLException
	{
		cstmt.setDouble(parameterName, x);
	}
	public void setBigDecimal(String parameterName,
			BigDecimal x)
	throws SQLException
	{
		cstmt.setBigDecimal(parameterName, x);
	}
	public void setString(String parameterName,
			String x)
	throws SQLException
	{
		cstmt.setString(parameterName, x);
	}
	public void setBytes(String parameterName,
			byte[] x)
	throws SQLException
	{
		cstmt.setBytes(parameterName, x);
	}
	public void setDate(String parameterName,
			Date x)
	throws SQLException
	{
		cstmt.setDate(parameterName, x);
	}
	public void setTime(String parameterName,
			Time x)
	throws SQLException
	{
		cstmt.setTime(parameterName, x);
	}
	public void setTimestamp(String parameterName,
			Timestamp x)
	throws SQLException
	{
		cstmt.setTimestamp(parameterName, x);
	}
	public void setAsciiStream(String parameterName,
			InputStream x,
			int length)
	throws SQLException
	{
		cstmt.setAsciiStream(parameterName, x, length);
	}
	public void setBinaryStream(String parameterName,
			InputStream x,
			int length)
	throws SQLException
	{
		cstmt.setBinaryStream(parameterName, x, length);
	}
	public void setObject(String parameterName,
			Object x,
			int targetSqlType,
			int scale)
	throws SQLException
	{
		cstmt.setObject(parameterName, x, targetSqlType, scale);
	}
	public void setObject(String parameterName,
			Object x,
			int targetSqlType)
	throws SQLException
	{
		cstmt.setObject(parameterName, x, targetSqlType);
	}
	public void setObject(String parameterName,
			Object x)
	throws SQLException
	{
		cstmt.setObject(parameterName, x);
	}
	public void setCharacterStream(String parameterName,
			Reader reader,
			int length)
	throws SQLException
	{
		cstmt.setCharacterStream(parameterName, reader, length);
	}
	public void setDate(String parameterName,
			Date x,
			Calendar cal)
	throws SQLException
	{
		cstmt.setDate(parameterName, x, cal);
	}
	public void setTime(String parameterName,
			Time x,
			Calendar cal)
	throws SQLException
	{
		cstmt.setTime(parameterName, x, cal);
	}
	public void setTimestamp(String parameterName,
			Timestamp x,
			Calendar cal)
	throws SQLException
	{
		cstmt.setTimestamp(parameterName, x, cal);
	}
	public void setNull(String parameterName,
			int sqlType,
			String typeName)
	throws SQLException
	{
		cstmt.setNull(parameterName, sqlType, typeName);
	}
	public String getString(String parameterName)
	throws SQLException
	{
		return cstmt.getString(parameterName);
	}
	public boolean getBoolean(String parameterName)
	throws SQLException
	{
		return cstmt.getBoolean(parameterName);
	}
	public byte getByte(String parameterName)
	throws SQLException
	{
		return cstmt.getByte(parameterName);
	}
	public short getShort(String parameterName)
	throws SQLException
	{
		return cstmt.getShort(parameterName);
	}
	public int getInt(String parameterName)
	throws SQLException
	{
		return cstmt.getInt(parameterName);
	}
	public long getLong(String parameterName)
	throws SQLException
	{
		return getLong(parameterName);
	}
	public float getFloat(String parameterName)
	throws SQLException
	{
		return cstmt.getFloat(parameterName);
	}
	public double getDouble(String parameterName)
	throws SQLException
	{
		return cstmt.getDouble(parameterName);
	}
	public byte[] getBytes(String parameterName)
	throws SQLException
	{
		return cstmt.getBytes(parameterName);
	}
	public Date getDate(String parameterName)
	throws SQLException
	{
		return cstmt.getDate(parameterName);
	}
	public Time getTime(String parameterName)
	throws SQLException
	{
		return cstmt.getTime(parameterName);
	}
	public Timestamp getTimestamp(String parameterName)
	throws SQLException
	{
		return cstmt.getTimestamp(parameterName);
	}
	public Object getObject(String parameterName)
	throws SQLException
	{
		return cstmt.getObject(parameterName);
	}
	public BigDecimal getBigDecimal(String parameterName)
	throws SQLException
	{
		return cstmt.getBigDecimal(parameterName);
	}
	public Object getObject(String parameterName,
			Map map)
	throws SQLException
	{
		return cstmt.getObject(parameterName, map);
	}
	public Ref getRef(String parameterName)
	throws SQLException
	{
		return cstmt.getRef(parameterName);
	}
	public Blob getBlob(String parameterName)
	throws SQLException
	{
		return cstmt.getBlob(parameterName);
	}
	public Clob getClob(String parameterName)
	throws SQLException
	{
		return cstmt.getClob(parameterName);
	}
	public Array getArray(String parameterName)
	throws SQLException
	{
		return cstmt.getArray(parameterName);
	}
	public Date getDate(String parameterName,
			Calendar cal)
	throws SQLException
	{
		return cstmt.getDate(parameterName, cal);
	}
	public Time getTime(String parameterName,
			Calendar cal)
	throws SQLException
	{
		return cstmt.getTime(parameterName, cal);
	}
	public Timestamp getTimestamp(String parameterName,
			Calendar cal)
	throws SQLException
	{
		return getTimestamp(parameterName, cal);
	}
	public URL getURL(String parameterName)
	throws SQLException
	{
		return cstmt.getURL(parameterName);
	}

        //jdk1.6
      public void setNClob(String parameterName,
                             Reader reader) throws SQLException {
          cstmt.setNClob(parameterName,reader);
      }
      public void setBlob(String parameterName,
             InputStream inputStream)
             throws SQLException{
         cstmt.setBlob(parameterName,inputStream);
     }
     public void setClob(String parameterName,
             java.io.Reader reader)
             throws SQLException{
         cstmt.setClob(parameterName,reader);
     }

     public void setNCharacterStream(String parameterName,
                                     java.io.Reader value) throws SQLException {
         cstmt.setNCharacterStream(parameterName,value);
     }
    public void setCharacterStream(String parameterName,
                                   java.io.Reader reader) throws SQLException{
        cstmt.setCharacterStream(parameterName,reader);
    }
    public void setBinaryStream(String parameterName,
                     InputStream x)
                     throws SQLException{
        cstmt.setBinaryStream(parameterName,x);
    }

    public void setAsciiStream(String parameterName,
                               InputStream x) throws SQLException{
        cstmt.setAsciiStream(parameterName,x);
    }

    public void setCharacterStream(String parameterName,
                                   java.io.Reader reader,
                                   long length) throws SQLException{
        cstmt.setCharacterStream(parameterName,reader,length);
    }

    public void setBinaryStream(String parameterName,
                                InputStream x,
                                long length) throws SQLException {
       cstmt.setBinaryStream(parameterName,x,length);
   }

   public void setAsciiStream(String parameterName,
                              InputStream x,
                              long length) throws SQLException{
       cstmt.setAsciiStream(parameterName,x,length);
   }

   public void setClob(String parameterName,
                       Clob x) throws SQLException{
       cstmt.setClob(parameterName,x);
   }

   public void setBlob(String parameterName,
                       Blob x) throws SQLException{
       cstmt.setBlob(parameterName,x);
   }

   public java.io.Reader getCharacterStream(String parameterName) throws
           SQLException{
       return cstmt.getCharacterStream(parameterName);
   }

   public java.io.Reader getCharacterStream(int parameterIndex) throws SQLException {
       return cstmt.getCharacterStream(parameterIndex);
   }

   public Reader getNCharacterStream(String parameterName) throws SQLException{
       return cstmt.getNCharacterStream(parameterName);
   }

   public Reader getNCharacterStream(int parameterIndex) throws SQLException{
       return cstmt.getNCharacterStream(parameterIndex);
   }

   public String getNString(String parameterName) throws SQLException {
       return cstmt.getNString(parameterName);
   }

   public String getNString(int parameterIndex) throws SQLException {
       return cstmt.getNString(parameterIndex);
   }

   public SQLXML getSQLXML(String parameterName) throws SQLException{
       return cstmt.getSQLXML(parameterName);
   }

   public SQLXML getSQLXML(int parameterIndex) throws SQLException {
       return cstmt.getSQLXML(parameterIndex);
   }

   public void setSQLXML(String parameterName,
                         SQLXML xmlObject) throws SQLException{
       cstmt.setSQLXML(parameterName,xmlObject);
   }

   public NClob getNClob(String parameterName) throws SQLException{
       return  cstmt.getNClob(parameterName);
   }

   public NClob getNClob(int parameterIndex) throws SQLException{
       return cstmt.getNClob(parameterIndex);
   }

   public void setNClob(String parameterName,
                        Reader reader,
                        long length) throws SQLException{
       cstmt.setNClob(parameterName,reader,length);
   }

   public void setBlob(String parameterName,
                       InputStream inputStream,
                       long length) throws SQLException {
      cstmt.setBlob(parameterName,inputStream,length);
  }

  public void setClob(String parameterName,
                      Reader reader,
                      long length) throws SQLException {
      cstmt.setClob(parameterName,reader,length);
  }

  public void setNClob(String parameterName,
                       NClob value) throws SQLException{
      cstmt.setNClob(parameterName,value);
  }

  public void setNCharacterStream(String parameterName,
                                  Reader value,
                                  long length) throws SQLException{
      cstmt.setNCharacterStream(parameterName,value,length);
  }

  public void setNString(String parameterName,
                         String value) throws SQLException{
      cstmt.setNString(parameterName,value);
  }

  public void setRowId(String parameterName,
                       RowId x) throws SQLException{
      cstmt.setRowId(parameterName,x);
  }

  public RowId getRowId(String parameterName) throws SQLException{
     return cstmt.getRowId(parameterName);
  }
  public RowId getRowId(int parameterIndex) throws SQLException{
      return cstmt.getRowId(parameterIndex);
  }

  public void setNClob(int parameterIndex, NClob value) throws SQLException {
      cstmt.setNClob(parameterIndex,value);
  }

  public void setClob(int parameterIndex, java.io.Reader reader, long length) throws
          SQLException {
      cstmt.setClob(parameterIndex,reader,length);
  }
}
